package org.dendy.app.ssh;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Shell;

import com.jcraft.jsch.JSchException;

public class ButtonToggle {

	protected Shell shell;

	protected Button button = null;

	Connection conn = null;

	public ButtonToggle(Shell shell) {
		this.shell = shell;
	}

	void buttonOff() {
		button = new Button(shell, SWT.PUSH);
		button.setText("Power Off");
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				conn = new Connection();
				try {
					conn.actionOff();
				} catch (JSchException event) {
					System.out.println("Error Poweroff");
				}
			}
		});
	}

	void buttonReboot() {
		button = new Button(shell, SWT.PUSH);
		button.setText("Reboot");
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent event) {
				conn = new Connection();
				try {
					conn.actionReboot();
				} catch (JSchException e) {
					System.out.println("error reboot");
				}
			}
		});
	}

}
